<template>
  <div class="toast" v-show="isShow">
    {{message}}
  </div>
</template>

<script>
  export default {
    name: "Toast",
    /*props: {
      message: {
        type: String,
        default: ''
      },
      show: {
        type: Boolean,
        default: false
      }
    }*/
    data() {
      return {
        message: '',
        isShow: false
      }
    },
    methods: {
      show(message='操作成功', duration=1500) {
        this.isShow = true
        this.message = message

        setTimeout(() => {
          this.isShow = false
          this.message = ''
        }, duration)
      }
    }
  }
</script>

<style scoped>
.toast{
  position: fixed;
  left: 50%;
  top: 50%;
  background: rgba(0, 0, 0, .75);
  color: #fff;
  padding: 5px 10px;
  transform: translate(-50%, -50%);
  z-index: 999;
  font-size: 14px;
}
</style>